package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.HotProductRecommendRequest;
import com.ytjj.qmyx.admin.service.HotProductRecommendService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 *
 * @Version: 1.0
 *
 * 爆品管理-推荐
 */
@RestController
@RequestMapping("/hotProductRecommend")
public class HotProductRecommendController {

    @Resource
    private HotProductRecommendService hotProductRecommendService;

    @GetMapping("/list")
    @OperLog(operModule = "爆品商品-推荐管理", operDesc = "推荐列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult selectList(HotProductRecommendRequest hotProductRecommendRequest) {
        return CommonResult.success(hotProductRecommendService.selectList(hotProductRecommendRequest));
    }

    @GetMapping("/insert")
    @OperLog(operModule = "爆品商品-推荐管理", operDesc = "新增", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult insertHotProductRecommend(@RequestParam Integer productId, @RequestParam Integer hotProductId, @RequestParam Integer sort) {
        return CommonResult.success(hotProductRecommendService.insertHotProductRecommend(productId, hotProductId, sort));
    }

    @GetMapping("/updateSort")
    @OperLog(operModule = "爆品商品-推荐管理", operDesc = "编辑排序", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateSort(@RequestParam Integer recommendId, @RequestParam Integer sort) {
        return CommonResult.success(hotProductRecommendService.updateSort(recommendId, sort));
    }

    @GetMapping("removeData")
    @OperLog(operModule = "爆品商品-推荐管理", operDesc = "移除", operType = SysLogConstants.OPERATION_DELETE)
    public CommonResult removeData(@RequestParam Integer recommendId) {
        return CommonResult.success(hotProductRecommendService.removeData(recommendId));
    }

}
